package com.lecture.java8.drools;//package com.lecture.java8.drools;
//
//import org.kie.api.KieServices;
//import org.kie.api.builder.KieScanner;
//import org.kie.api.runtime.KieContainer;
//import org.kie.api.runtime.KieSession;
//
//public class KieSessionFactory {
//    private static KieContainer kieContainer;
//    private static KieScanner kieScanner;
//    private static KieSession kieSession;
//
//    public static synchronized KieSession getKieSession() {
//        if (kieSession == null) {
//            KieServices kieServices = KieServices.Factory.get();
//            kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId());
//            kieScanner = kieServices.newKieScanner(kieContainer);
//            kieScanner.start(10000L); // 每隔10秒扫描并加载新规则
//            kieSession = kieContainer.newKieSession();
//        }
//        return kieSession;
//    }
//
//    public static void triggerRulesScan() {
//        kieScanner.scanNow();
//    }
//}
//
//
